<form action="" method="get">
    <select name="q" id="">
        <option value="">选择一个炮友</option>
        <option value="long">小龙女</option>
        <option value="qi">七仙女</option>
    </select>
    <input type="submit" value="提交你的炮友">
</form>
<?php

//isset() 检测变量是否已设置并且非空
//htmlspecialchars()将特殊字符转换成html实体
//$_GET[] 收集表单数据

$q = isset($_GET['q'])?htmlspecialchars($_GET['q']):'';
switch ($q){
    case $q=='long':
        echo '我爱小龙女';
        break;
    case $q == 'qi':
        echo "我爱七仙女";
        break;
    default:
        echo "我爱美女";

}
?>

<?php
$q = isset($_GET['q'])? htmlspecialchars($_GET['q']) : '';
if($q) {
    if($q =='RUNOOB') {
        echo '菜鸟教程<br>http://www.runoob.com';
    } else if($q =='GOOGLE') {
        echo 'Google 搜索<br>http://www.google.com';
    } else if($q =='TAOBAO') {
        echo '淘宝<br>http://www.taobao.com';
    }
} else {
    ?>
    <form action="" method="get">
        <select name="q">
            <option value="">选择一个站点:</option>
            <option value="RUNOOB">Runoob</option>
            <option value="GOOGLE">Google</option>
            <option value="TAOBAO">Taobao</option>
        </select>
        <input type="submit" value="提交">
    </form>
    <?php
}
?>
